

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>pysimm.forcefield.gasteiger &mdash; pysimm 0.2 documentation</title>
  

  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  

  

  
    <link rel="top" title="pysimm 0.2 documentation" href="../../../index.html"/>
        <link rel="up" title="pysimm" href="../../pysimm.html"/> 

  
  <script src="../../../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../../../index.html" class="icon icon-home"> pysimm
          

          
          </a>

          
            
            
              <div class="version">
                0.2
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
                <ul>
<li class="toctree-l1"><a class="reference internal" href="../../../pysimm.html">pysimm package</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="../../../index.html">pysimm</a>
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          





<div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="../../../index.html">Docs</a> &raquo;</li>
      
          <li><a href="../../index.html">Module code</a> &raquo;</li>
      
          <li><a href="../../pysimm.html">pysimm</a> &raquo;</li>
      
    <li>pysimm.forcefield.gasteiger</li>
      <li class="wy-breadcrumbs-aside">
        
          
        
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for pysimm.forcefield.gasteiger</h1><div class="highlight"><pre>
<span></span><span class="c1"># ******************************************************************************</span>
<span class="c1"># pysimm.gasteiger module</span>
<span class="c1"># ******************************************************************************</span>
<span class="c1">#</span>
<span class="c1"># gasteiger algorithm and parameters (to be moved to pysimm.forcefield)</span>
<span class="c1">#</span>
<span class="c1"># ******************************************************************************</span>
<span class="c1"># License</span>
<span class="c1"># ******************************************************************************</span>
<span class="c1"># The MIT License (MIT)</span>
<span class="c1">#</span>
<span class="c1"># Copyright (c) 2016 Michael E. Fortunato, Coray M. Colina</span>
<span class="c1">#</span>
<span class="c1"># Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<span class="c1"># of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<span class="c1"># in the Software without restriction, including without limitation the rights</span>
<span class="c1"># to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
<span class="c1"># copies of the Software, and to permit persons to whom the Software is</span>
<span class="c1"># furnished to do so, subject to the following conditions:</span>
<span class="c1">#</span>
<span class="c1"># The above copyright notice and this permission notice shall be included in</span>
<span class="c1"># all copies or substantial portions of the Software.</span>
<span class="c1">#</span>
<span class="c1"># THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<span class="c1"># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<span class="c1"># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
<span class="c1"># AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<span class="c1"># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<span class="c1"># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN</span>
<span class="c1"># THE SOFTWARE.</span>

<span class="kn">from</span> <span class="nn">pysimm</span> <span class="kn">import</span> <span class="n">error_print</span>
<span class="kn">from</span> <span class="nn">pysimm</span> <span class="kn">import</span> <span class="n">warning_print</span>
<span class="kn">from</span> <span class="nn">pysimm</span> <span class="kn">import</span> <span class="n">verbose_print</span>
<span class="kn">from</span> <span class="nn">pysimm</span> <span class="kn">import</span> <span class="n">debug_print</span>
<span class="kn">from</span> <span class="nn">pysimm.utils</span> <span class="kn">import</span> <span class="n">Item</span><span class="p">,</span> <span class="n">ItemContainer</span>

<span class="n">element_names_by_mass</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">:</span> <span class="s1">&#39;H&#39;</span><span class="p">,</span> <span class="mi">4</span><span class="p">:</span> <span class="s1">&#39;He&#39;</span><span class="p">,</span> <span class="mi">7</span><span class="p">:</span> <span class="s1">&#39;Li&#39;</span><span class="p">,</span> <span class="mi">9</span><span class="p">:</span> <span class="s1">&#39;Be&#39;</span><span class="p">,</span> <span class="mi">11</span><span class="p">:</span> <span class="s1">&#39;B&#39;</span><span class="p">,</span> <span class="mi">12</span><span class="p">:</span> <span class="s1">&#39;C&#39;</span><span class="p">,</span>
                         <span class="mi">14</span><span class="p">:</span> <span class="s1">&#39;N&#39;</span><span class="p">,</span> <span class="mi">16</span><span class="p">:</span> <span class="s1">&#39;O&#39;</span><span class="p">,</span> <span class="mi">19</span><span class="p">:</span> <span class="s1">&#39;F&#39;</span><span class="p">,</span> <span class="mi">20</span><span class="p">:</span> <span class="s1">&#39;Ne&#39;</span><span class="p">,</span> <span class="mi">23</span><span class="p">:</span> <span class="s1">&#39;Na&#39;</span><span class="p">,</span>
                         <span class="mi">24</span><span class="p">:</span> <span class="s1">&#39;Mg&#39;</span><span class="p">,</span> <span class="mi">27</span><span class="p">:</span> <span class="s1">&#39;Al&#39;</span><span class="p">,</span> <span class="mi">28</span><span class="p">:</span> <span class="s1">&#39;Si&#39;</span><span class="p">,</span> <span class="mi">31</span><span class="p">:</span> <span class="s1">&#39;P&#39;</span><span class="p">,</span> <span class="mi">32</span><span class="p">:</span> <span class="s1">&#39;S&#39;</span><span class="p">,</span>
                         <span class="mi">35</span><span class="p">:</span> <span class="s1">&#39;Cl&#39;</span><span class="p">,</span> <span class="mi">39</span><span class="p">:</span> <span class="s1">&#39;K&#39;</span><span class="p">,</span> <span class="mi">40</span><span class="p">:</span> <span class="s1">&#39;Ca&#39;</span><span class="p">,</span> <span class="mi">80</span><span class="p">:</span> <span class="s1">&#39;Br&#39;</span><span class="p">,</span> <span class="mi">127</span><span class="p">:</span> <span class="s1">&#39;I&#39;</span><span class="p">}</span>

<span class="n">gasteiger_parameters</span> <span class="o">=</span> <span class="n">ItemContainer</span><span class="p">()</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;H_&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;H_&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">7.17</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">6.24</span><span class="p">,</span> <span class="n">c</span><span class="o">=-</span><span class="mf">0.56</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;C_3&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;C_3&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">7.98</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.18</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">1.88</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;C_2&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;C_2&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">8.79</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.32</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">1.51</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;C_R&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;C_R&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">8.79</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.32</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">1.51</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;C_1&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;C_1&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">10.39</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.45</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">0.73</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;N_3&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;N_3&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">11.54</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">10.82</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">1.36</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;N_2&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;N_2&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">12.87</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">11.15</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">0.85</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;N_R&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;N_R&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">12.87</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">11.15</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">0.85</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;N_1&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;N_1&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">15.68</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">11.7</span><span class="p">,</span> <span class="n">c</span><span class="o">=-</span><span class="mf">0.27</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;O_3&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;O_3&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">14.18</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">12.92</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">1.39</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;O_2&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;O_2&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">17.07</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">13.79</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">0.47</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;O_R&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;O_R&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">17.07</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">13.79</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">0.47</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;F_&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;F_&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">14.66</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">13.85</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">2.31</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;Cl_&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;Cl_&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">11.00</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.69</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">1.35</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;Br_&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;Br_&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">10.08</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">8.47</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">1.16</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;I_&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;I_&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">9.90</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">7.96</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">0.96</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;S_&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;S_&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">10.14</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.13</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">1.38</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;S_3&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;S_3&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">10.14</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.13</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">1.38</span><span class="p">))</span>

<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;h&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;h&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">7.17</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">6.24</span><span class="p">,</span> <span class="n">c</span><span class="o">=-</span><span class="mf">0.56</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;c_sp3&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;c_sp3&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">7.98</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.18</span><span class="p">,</span>
                              <span class="n">c</span><span class="o">=</span><span class="mf">1.88</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;c_sp2&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;c_sp2&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">8.79</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.32</span><span class="p">,</span>
                              <span class="n">c</span><span class="o">=</span><span class="mf">1.51</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;c_sp1&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;c_sp1&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">10.39</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.45</span><span class="p">,</span>
                              <span class="n">c</span><span class="o">=</span><span class="mf">0.73</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;n_sp3&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;n_sp3&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">11.54</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">10.82</span><span class="p">,</span>
                              <span class="n">c</span><span class="o">=</span><span class="mf">1.36</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;n_sp2&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;n_sp2&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">12.87</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">11.15</span><span class="p">,</span>
                              <span class="n">c</span><span class="o">=</span><span class="mf">0.85</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;n_sp1&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;n_sp1&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">15.68</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">11.7</span><span class="p">,</span>
                              <span class="n">c</span><span class="o">=-</span><span class="mf">0.27</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;o_sp3&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;o_sp3&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">14.18</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">12.92</span><span class="p">,</span>
                              <span class="n">c</span><span class="o">=</span><span class="mf">1.39</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;o_sp2&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;o_sp2&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">17.07</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">13.79</span><span class="p">,</span>
                              <span class="n">c</span><span class="o">=</span><span class="mf">0.47</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;f&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;f&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">14.66</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">13.85</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">2.31</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;cl&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;cl&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">11.00</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.69</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">1.35</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;br&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;br&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">10.08</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">8.47</span><span class="p">,</span>
                              <span class="n">c</span><span class="o">=</span><span class="mf">1.16</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;i&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;i&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">9.90</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">7.96</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">0.96</span><span class="p">))</span>
<span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Item</span><span class="p">(</span><span class="n">tag</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">10.14</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mf">9.13</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="mf">1.38</span><span class="p">))</span>


<div class="viewcode-block" id="set_charges"><a class="viewcode-back" href="../../../pysimm.forcefield.gasteiger.html#pysimm.forcefield.gasteiger.set_charges">[docs]</a><span class="k">def</span> <span class="nf">set_charges</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">maxiter</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">tol</span><span class="o">=</span><span class="mf">1e-6</span><span class="p">):</span>
    <span class="k">global</span> <span class="n">gasteiger_parameters</span>

    <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">s</span><span class="o">.</span><span class="n">particles</span><span class="p">:</span>

        <span class="k">if</span> <span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">type</span> <span class="ow">and</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">name</span> <span class="ow">and</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;@&#39;</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="ow">and</span>
                <span class="n">s</span><span class="o">.</span><span class="n">particle_types</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;@&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">])):</span>
            <span class="n">p</span><span class="o">.</span><span class="n">nbonds</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">bonds</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span>
            <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">name</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;H&#39;</span><span class="p">:</span>
                <span class="n">p</span><span class="o">.</span><span class="n">linker</span> <span class="o">=</span> <span class="s1">&#39;head&#39;</span>
            <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">name</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;T&#39;</span><span class="p">:</span>
                <span class="n">p</span><span class="o">.</span><span class="n">linker</span> <span class="o">=</span> <span class="s1">&#39;tail&#39;</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">p</span><span class="o">.</span><span class="n">linker</span> <span class="o">=</span> <span class="bp">True</span>
            <span class="n">type_</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">particle_types</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;@&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
            <span class="k">if</span> <span class="n">type_</span><span class="p">:</span>
                <span class="n">p</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">type_</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">error_print</span><span class="p">(</span><span class="s1">&#39;found linker type </span><span class="si">%s</span><span class="s1"> but did not find regular &#39;</span>
                            <span class="s1">&#39;type </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
                                         <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;@&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]))</span>
                <span class="k">return</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">p</span><span class="o">.</span><span class="n">nbonds</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">bonds</span><span class="p">)</span>

        <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">gast_type</span><span class="p">:</span>
            <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gast_type</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">p</span><span class="o">.</span><span class="n">gast_conv</span> <span class="o">=</span> <span class="bp">False</span>
            <span class="n">p</span><span class="o">.</span><span class="n">qn</span> <span class="o">=</span> <span class="mf">0.0</span>
            <span class="n">p</span><span class="o">.</span><span class="n">charge</span> <span class="o">=</span> <span class="mf">0.0</span>
            <span class="n">p</span><span class="o">.</span><span class="n">gast_a</span> <span class="o">=</span> <span class="n">gast_type</span><span class="o">.</span><span class="n">a</span>
            <span class="n">p</span><span class="o">.</span><span class="n">chi</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">gast_a</span>
            <span class="n">p</span><span class="o">.</span><span class="n">gast_b</span> <span class="o">=</span> <span class="n">gast_type</span><span class="o">.</span><span class="n">b</span>
            <span class="n">p</span><span class="o">.</span><span class="n">gast_c</span> <span class="o">=</span> <span class="n">gast_type</span><span class="o">.</span><span class="n">c</span>
            <span class="k">continue</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="ow">and</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">mass</span><span class="p">:</span>
                <span class="n">elem</span> <span class="o">=</span> <span class="n">element_names_by_mass</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="nb">round</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">mass</span><span class="p">)))</span>
                <span class="k">if</span> <span class="n">elem</span><span class="p">:</span>
                    <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="o">=</span> <span class="n">elem</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="ow">or</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;H&#39;</span><span class="p">,</span> <span class="s1">&#39;N&#39;</span><span class="p">,</span> <span class="s1">&#39;C&#39;</span><span class="p">,</span> <span class="s1">&#39;O&#39;</span><span class="p">,</span>
                                                      <span class="s1">&#39;F&#39;</span><span class="p">,</span> <span class="s1">&#39;Cl&#39;</span><span class="p">,</span> <span class="s1">&#39;Br&#39;</span><span class="p">,</span> <span class="s1">&#39;I&#39;</span><span class="p">,</span>
                                                      <span class="s1">&#39;S&#39;</span><span class="p">]:</span>
                <span class="n">error_print</span><span class="p">(</span><span class="s1">&#39;cannot find gastieger paramater for particle </span><span class="si">%s</span><span class="s1">&#39;</span>
                            <span class="o">%</span> <span class="n">p</span><span class="o">.</span><span class="n">tag</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;H&#39;</span><span class="p">:</span>
                    <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;h&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;C&#39;</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">nbonds</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span>
                        <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;c_sp3&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">nbonds</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
                        <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;c_sp2&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">nbonds</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                        <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;c_sp1&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;N&#39;</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">nbonds</span> <span class="o">&gt;=</span> <span class="mi">3</span><span class="p">:</span>
                        <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;n_sp3&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">nbonds</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                        <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;c_sp2&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">nbonds</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                        <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;c_sp1&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;O&#39;</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">nbonds</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                        <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;o_sp3&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">nbonds</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                        <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;o_sp2&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;F&#39;</span><span class="p">:</span>
                    <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;f&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;Cl&#39;</span><span class="p">:</span>
                    <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;cl&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;Br&#39;</span><span class="p">:</span>
                    <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;br&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;I&#39;</span><span class="p">:</span>
                    <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;i&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
                <span class="k">elif</span> <span class="n">p</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;S&#39;</span><span class="p">:</span>
                    <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gasteiger_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;s&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>

                <span class="n">gast_type</span> <span class="o">=</span> <span class="n">gast_type</span>
                <span class="n">p</span><span class="o">.</span><span class="n">gast_conv</span> <span class="o">=</span> <span class="bp">False</span>
                <span class="n">p</span><span class="o">.</span><span class="n">qn</span> <span class="o">=</span> <span class="mf">0.0</span>
                <span class="n">p</span><span class="o">.</span><span class="n">charge</span> <span class="o">=</span> <span class="mf">0.0</span>
                <span class="n">p</span><span class="o">.</span><span class="n">gast_a</span> <span class="o">=</span> <span class="n">gast_type</span><span class="o">.</span><span class="n">a</span>
                <span class="n">p</span><span class="o">.</span><span class="n">chi</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">gast_a</span>
                <span class="n">p</span><span class="o">.</span><span class="n">gast_b</span> <span class="o">=</span> <span class="n">gast_type</span><span class="o">.</span><span class="n">b</span>
                <span class="n">p</span><span class="o">.</span><span class="n">gast_c</span> <span class="o">=</span> <span class="n">gast_type</span><span class="o">.</span><span class="n">c</span>
                <span class="k">continue</span>

    <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">maxiter</span><span class="o">+</span><span class="mi">1</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">s</span><span class="o">.</span><span class="n">bonds</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">chi</span> <span class="o">&gt;</span> <span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">chi</span><span class="p">:</span>
                <span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">qn</span> <span class="o">+=</span> <span class="p">((</span><span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">chi</span> <span class="o">-</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">chi</span><span class="p">)</span> <span class="o">/</span>
                           <span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">gast_a</span> <span class="o">+</span> <span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">gast_b</span> <span class="o">+</span> <span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">gast_c</span><span class="p">))</span>
                <span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">qn</span> <span class="o">+=</span> <span class="p">((</span><span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">chi</span> <span class="o">-</span> <span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">chi</span><span class="p">)</span> <span class="o">/</span>
                           <span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">gast_a</span> <span class="o">+</span> <span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">gast_b</span> <span class="o">+</span> <span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">gast_c</span><span class="p">))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">qn</span> <span class="o">+=</span> <span class="p">((</span><span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">chi</span> <span class="o">-</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">chi</span><span class="p">)</span> <span class="o">/</span>
                           <span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">gast_a</span> <span class="o">+</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">gast_b</span> <span class="o">+</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">gast_c</span><span class="p">))</span>
                <span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">qn</span> <span class="o">+=</span> <span class="p">((</span><span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">chi</span> <span class="o">-</span> <span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">chi</span><span class="p">)</span> <span class="o">/</span>
                           <span class="p">(</span><span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">gast_a</span> <span class="o">+</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">gast_b</span> <span class="o">+</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">gast_c</span><span class="p">))</span>

        <span class="n">convergence</span> <span class="o">=</span> <span class="bp">True</span>
        <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">s</span><span class="o">.</span><span class="n">particles</span><span class="p">:</span>
            <span class="n">p</span><span class="o">.</span><span class="n">qn</span> <span class="o">*=</span> <span class="nb">pow</span><span class="p">(</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">n</span><span class="p">)</span>
            <span class="n">p</span><span class="o">.</span><span class="n">charge</span> <span class="o">+=</span> <span class="n">p</span><span class="o">.</span><span class="n">qn</span>
            <span class="n">p</span><span class="o">.</span><span class="n">chi</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">gast_a</span> <span class="o">+</span> <span class="n">p</span><span class="o">.</span><span class="n">gast_b</span><span class="o">*</span><span class="n">p</span><span class="o">.</span><span class="n">charge</span> <span class="o">+</span> <span class="n">p</span><span class="o">.</span><span class="n">gast_c</span><span class="o">*</span><span class="n">p</span><span class="o">.</span><span class="n">charge</span><span class="o">*</span><span class="n">p</span><span class="o">.</span><span class="n">charge</span>
            <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">qn</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">tol</span><span class="p">:</span>
                <span class="n">p</span><span class="o">.</span><span class="n">gast_conv</span> <span class="o">=</span> <span class="bp">True</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">convergence</span> <span class="o">=</span> <span class="bp">False</span>
            <span class="n">p</span><span class="o">.</span><span class="n">qn</span> <span class="o">=</span> <span class="mf">0.0</span>

        <span class="k">if</span> <span class="n">convergence</span><span class="p">:</span>
            <span class="k">print</span><span class="p">(</span><span class="s1">&#39;charges converged after </span><span class="si">%s</span><span class="s1"> iterations&#39;</span> <span class="o">%</span> <span class="n">n</span><span class="p">)</span>
            <span class="k">break</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">convergence</span><span class="p">:</span>
        <span class="k">print</span><span class="p">(</span><span class="s1">&#39;charges not converged after </span><span class="si">%s</span><span class="s1"> iterations&#39;</span> <span class="o">%</span> <span class="n">n</span><span class="p">)</span></div>
</pre></div>

           </div>
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2017, https://pysimm.org.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../../../',
            VERSION:'0.2',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true
        };
    </script>
      <script type="text/javascript" src="../../../_static/jquery.js"></script>
      <script type="text/javascript" src="../../../_static/underscore.js"></script>
      <script type="text/javascript" src="../../../_static/doctools.js"></script>

  

  
  
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>